import os

from classpath.entry import Entry


class DirEntry(Entry):

    def __init__(self, absPath):
        self.absPath = absPath

    def readClass(self, className):
        absFile = os.path.join(self.absPath, className)
        data = []
        with open(absFile, "rb") as f:
            data = f.read()
        return data, self

    def __str__(self):
        return self.absPath

    @staticmethod
    def newDirEntry(path):
        return DirEntry(os.path.abspath(path))
